home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / c / xw2.000 / xw2 / xw / csource / makemfx / makemfxparser.tab.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-02  |  44.3 KB  |  1,444 lines

  1.  
  2. /*  A Bison parser, made from makemfxparser.y with Bison version GNU Bison version 1.22
  3.   */
  4.  
  5. #define YYBISON 1  /* Identify Bison output.  */
  6.  
  7. #define    NUMBER    258
  8. #define    NAME    259
  9. #define    INT    260
  10. #define    DOUBLE    261
  11. #define    STRING    262
  12. #define    SHORT    263
  13. #define    TYPEDEF    264
  14. #define    STRUCT    265
  15. #define    EXTERN    266
  16. #define    DEFINE    267
  17. #define    IFDEF    268
  18. #define    ENDIF    269
  19. #define    PGMNAME    270
  20. #define    MFXINIT    271
  21. #define    HIPREC    272
  22.  
  23. #line 1 "makemfxparser.y"
  24.  
  25.  
  26. #include <stdlib.h>
  27. #include <stdio.h>
  28. #include <string.h>
  29. #include <unistd.h>
  30. #include <ctype.h>
  31.  
  32. int yyerror(char*s){ printf(s); return(0); }
  33. void create_c_files(void);
  34. int write_c_files(char *s, char *pgm);
  35.  
  36. int struct_defined=0;
  37.  
  38. FILE *fp_xbc;
  39. FILE *fp_xbm;
  40. FILE *fp_wdw;
  41. FILE *fp_trl;
  42.  
  43. FILE *fp_wmfx;
  44. FILE *fp_rmfx;
  45. FILE *fp_dmfx;
  46. FILE *fp_dwdw;
  47.  
  48. char pgmname[100];
  49. char c_struct_name[100];
  50. char c_var_name[100];
  51. int obj=0;
  52.  
  53. int wdwnr=0;
  54.  
  55.  
  56. #line 34 "makemfxparser.y"
  57. typedef union { char sstr[100]; int val; } YYSTYPE;
  58.  
  59. #ifndef YYLTYPE
  60. typedef
  61.   struct yyltype
  62.     {
  63.       int timestamp;
  64.       int first_line;
  65.       int first_column;
  66.       int last_line;
  67.       int last_column;
  68.       char *text;
  69.    }
  70.   yyltype;
  71.  
  72. #define YYLTYPE yyltype
  73. #endif
  74.  
  75. #include <stdio.h>
  76.  
  77. #ifndef __cplusplus
  78. #ifndef __STDC__
  79. #define const
  80. #endif
  81. #endif
  82.  
  83.  
  84.  
  85. #define    YYFINAL        77
  86. #define    YYFLAG        -32768
  87. #define    YYNTBASE    23
  88.  
  89. #define YYTRANSLATE(x) ((unsigned)(x) <= 272 ? yytranslate[x] : 25)
  90.  
  91. static const char yytranslate[] = {     0,
  92.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  93.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  94.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  95.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  96.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  97.      2,     2,     2,     2,     2,     2,     2,     2,    21,     2,
  98.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  99.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  100.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  101.     18,     2,    17,     2,     2,     2,     2,     2,     2,     2,
  102.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  103.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  104.      2,     2,    20,     2,    19,     2,     2,     2,     2,     2,
  105.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  106.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  107.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  108.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  109.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  110.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  111.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  112.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  113.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  114.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  115.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  116.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  117.      2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
  118.      6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
  119.     16,    22
  120. };
  121.  
  122. #if YYDEBUG != 0
  123. static const short yyprhs[] = {     0,
  124.      0,     1,     4,     8,    12,    17,    21,    25,    29,    31,
  125.     33,    37,    44,    54,    67,    71,    78,    88,   101,   108,
  126.    118,   122,   129,   139
  127. };
  128.  
  129. static const short yyrhs[] = {    -1,
  130.     23,    24,     0,     9,    10,    20,     0,    19,     4,    21,
  131.      0,    11,     4,     4,    21,     0,    12,     4,     4,     0,
  132.     12,     4,     3,     0,    12,    15,     4,     0,    13,     0,
  133.     14,     0,     5,     4,    21,     0,     5,     4,    18,     3,
  134.     17,    21,     0,     5,     4,    18,     3,    17,    18,     3,
  135.     17,    21,     0,     5,     4,    18,     3,    17,    18,     3,
  136.     17,    18,     3,    17,    21,     0,     6,     4,    21,     0,
  137.      6,     4,    18,     3,    17,    21,     0,     6,     4,    18,
  138.      3,    17,    18,     3,    17,    21,     0,     6,     4,    18,
  139.      3,    17,    18,     3,    17,    18,     3,    17,    21,     0,
  140.      7,     4,    18,     3,    17,    21,     0,     7,     4,    18,
  141.      3,    17,    18,     3,    17,    21,     0,     8,     4,    21,
  142.      0,     8,     4,    18,     3,    17,    21,     0,     8,     4,
  143.     18,     3,    17,    18,     3,    17,    21,     0,     8,     4,
  144.     18,     3,    17,    18,     3,    17,    18,     3,    17,    21,
  145.      0
  146. };
  147.  
  148. #endif
  149.  
  150. #if YYDEBUG != 0
  151. static const short yyrline[] = { 0,
  152.     63,    64,    66,    70,    74,    79,    80,    81,    97,    98,
  153.    102,   115,   128,   144,   163,   178,   191,   207,   226,   239,
  154.    252,   265,   278,   294
  155. };
  156.  
  157. static const char * const yytname[] = {   "$","error","$illegal.","NUMBER","NAME",
  158. "INT","DOUBLE","STRING","SHORT","TYPEDEF","STRUCT","EXTERN","DEFINE","IFDEF",
  159. "ENDIF","PGMNAME","MFXINIT","']'","'['","'}'","'{'","';'","HIPREC","input","v",
  160. ""
  161. };
  162. #endif
  163.  
  164. static const short yyr1[] = {     0,
  165.     23,    23,    24,    24,    24,    24,    24,    24,    24,    24,
  166.     24,    24,    24,    24,    24,    24,    24,    24,    24,    24,
  167.     24,    24,    24,    24
  168. };
  169.  
  170. static const short yyr2[] = {     0,
  171.      0,     2,     3,     3,     4,     3,     3,     3,     1,     1,
  172.      3,     6,     9,    12,     3,     6,     9,    12,     6,     9,
  173.      3,     6,     9,    12
  174. };
  175.  
  176. static const short yydefact[] = {     1,
  177.      0,     0,     0,     0,     0,     0,     0,     0,     9,    10,
  178.      0,     2,     0,     0,     0,     0,     0,     0,     0,     0,
  179.      0,     0,    11,     0,    15,     0,     0,    21,     3,     0,
  180.      7,     6,     8,     4,     0,     0,     0,     0,     5,     0,
  181.      0,     0,     0,     0,    12,     0,    16,     0,    19,     0,
  182.     22,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  183.     13,     0,    17,    20,     0,    23,     0,     0,     0,     0,
  184.      0,     0,    14,    18,    24,     0,     0
  185. };
  186.  
  187. static const short yydefgoto[] = {     1,
  188.     12
  189. };
  190.  
  191. static const short yypact[] = {-32768,
  192.      0,    -2,    12,    20,    31,    -7,    36,     6,-32768,-32768,
  193.     37,-32768,   -17,    -3,    24,    -1,    23,    40,    35,    41,
  194.     25,    44,-32768,    45,-32768,    46,    47,-32768,-32768,    30,
  195. -32768,-32768,-32768,-32768,    38,    39,    42,    43,-32768,     4,
  196.      5,     9,    10,    49,-32768,    50,-32768,    51,-32768,    54,
  197. -32768,    48,    52,    53,    55,    11,    15,    56,    16,    58,
  198. -32768,    59,-32768,-32768,    60,-32768,    57,    61,    62,    63,
  199.     64,    65,-32768,-32768,-32768,    66,-32768
  200. };
  201.  
  202. static const short yypgoto[] = {-32768,
  203. -32768
  204. };
  205.  
  206.  
  207. #define    YYLAST        86
  208.  
  209.  
  210. static const short yytable[] = {    76,
  211.     22,    13,    17,    23,     2,     3,     4,     5,     6,    19,
  212.      7,     8,     9,    10,    24,    14,    27,    25,    11,    28,
  213.     20,    44,    46,    15,    45,    47,    48,    50,    60,    49,
  214.     51,    61,    62,    65,    16,    63,    66,    31,    32,    18,
  215.     21,    26,    29,    30,    33,    34,    35,    36,    37,    38,
  216.     39,    52,    53,    54,    40,    41,    55,     0,    42,    43,
  217.     67,    68,    69,     0,    56,    77,     0,     0,    57,    58,
  218.      0,    59,     0,    70,     0,     0,    64,    71,    72,     0,
  219.      0,     0,     0,    73,    74,    75
  220. };
  221.  
  222. static const short yycheck[] = {     0,
  223.     18,     4,    10,    21,     5,     6,     7,     8,     9,     4,
  224.     11,    12,    13,    14,    18,     4,    18,    21,    19,    21,
  225.     15,    18,    18,     4,    21,    21,    18,    18,    18,    21,
  226.     21,    21,    18,    18,     4,    21,    21,     3,     4,     4,
  227.      4,    18,    20,     4,     4,    21,     3,     3,     3,     3,
  228.     21,     3,     3,     3,    17,    17,     3,    -1,    17,    17,
  229.      3,     3,     3,    -1,    17,     0,    -1,    -1,    17,    17,
  230.     -1,    17,    -1,    17,    -1,    -1,    21,    17,    17,    -1,
  231.     -1,    -1,    -1,    21,    21,    21
  232. };
  233. /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
  234. #line 3 "/usr/lib/bison.simple"
  235.  
  236. /* Skeleton output parser for bison,
  237.    Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman
  238.  
  239.    This program is free software; you can redistribute it and/or modify
  240.    it under the terms of the GNU General Public License as published by
  241.    the Free Software Foundation; either version 1, or (at your option)
  242.    any later version.
  243.  
  244.    This program is distributed in the hope that it will be useful,
  245.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  246.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  247.    GNU General Public License for more details.
  248.  
  249.    You should have received a copy of the GNU General Public License
  250.    along with this program; if not, write to the Free Software
  251.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  252.  
  253.  
  254. #ifndef alloca
  255. #ifdef __GNUC__
  256. #define alloca __builtin_alloca
  257. #else /* not GNU C.  */
  258. #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
  259. #include <alloca.h>
  260. #else /* not sparc */
  261. #if defined (MSDOS) && !defined (__TURBOC__)
  262. #include <malloc.h>
  263. #else /* not MSDOS, or __TURBOC__ */
  264. #if defined(_AIX)
  265. #include <malloc.h>
  266.  #pragma alloca
  267. #else /* not MSDOS, __TURBOC__, or _AIX */
  268. #ifdef __hpux
  269. #ifdef __cplusplus
  270. extern "C" {
  271. void *alloca (unsigned int);
  272. };
  273. #else /* not __cplusplus */
  274. void *alloca ();
  275. #endif /* not __cplusplus */
  276. #endif /* __hpux */
  277. #endif /* not _AIX */
  278. #endif /* not MSDOS, or __TURBOC__ */
  279. #endif /* not sparc.  */
  280. #endif /* not GNU C.  */
  281. #endif /* alloca not defined.  */
  282.  
  283. /* This is the parser code that is written into each bison parser
  284.   when the %semantic_parser declaration is not specified in the grammar.
  285.   It was written by Richard Stallman by simplifying the hairy parser
  286.   used when %semantic_parser is specified.  */
  287.  
  288. /* Note: there must be only one dollar sign in this file.
  289.    It is replaced by the list of actions, each action
  290.    as one case of the switch.  */
  291.  
  292. #define yyerrok        (yyerrstatus = 0)
  293. #define yyclearin    (yychar = YYEMPTY)
  294. #define YYEMPTY        -2
  295. #define YYEOF        0
  296. #define YYACCEPT    return(0)
  297. #define YYABORT     return(1)
  298. #define YYERROR        goto yyerrlab1
  299. /* Like YYERROR except do call yyerror.
  300.    This remains here temporarily to ease the
  301.    transition to the new meaning of YYERROR, for GCC.
  302.    Once GCC version 2 has supplanted version 1, this can go.  */
  303. #define YYFAIL        goto yyerrlab
  304. #define YYRECOVERING()  (!!yyerrstatus)
  305. #define YYBACKUP(token, value) \
  306. do                                \
  307.   if (yychar == YYEMPTY && yylen == 1)                \
  308.     { yychar = (token), yylval = (value);            \
  309.       yychar1 = YYTRANSLATE (yychar);                \
  310.       YYPOPSTACK;                        \
  311.       goto yybackup;                        \
  312.     }                                \
  313.   else                                \
  314.     { yyerror ("syntax error: cannot back up"); YYERROR; }    \
  315. while (0)
  316.  
  317. #define YYTERROR    1
  318. #define YYERRCODE    256
  319.  
  320. #ifndef YYPURE
  321. #define YYLEX        yylex()
  322. #endif
  323.  
  324. #ifdef YYPURE
  325. #ifdef YYLSP_NEEDED
  326. #define YYLEX        yylex(&yylval, &yylloc)
  327. #else
  328. #define YYLEX        yylex(&yylval)
  329. #endif
  330. #endif
  331.  
  332. /* If nonreentrant, generate the variables here */
  333.  
  334. #ifndef YYPURE
  335.  
  336. int    yychar;            /*  the lookahead symbol        */
  337. YYSTYPE    yylval;            /*  the semantic value of the        */
  338.                 /*  lookahead symbol            */
  339.  
  340. #ifdef YYLSP_NEEDED
  341. YYLTYPE yylloc;            /*  location data for the lookahead    */
  342.                 /*  symbol                */
  343. #endif
  344.  
  345. int yynerrs;            /*  number of parse errors so far       */
  346. #endif  /* not YYPURE */
  347.  
  348. #if YYDEBUG != 0
  349. int yydebug;            /*  nonzero means print parse trace    */
  350. /* Since this is uninitialized, it does not stop multiple parsers
  351.    from coexisting.  */
  352. #endif
  353.  
  354. /*  YYINITDEPTH indicates the initial size of the parser's stacks    */
  355.  
  356. #ifndef    YYINITDEPTH
  357. #define YYINITDEPTH 200
  358. #endif
  359.  
  360. /*  YYMAXDEPTH is the maximum size the stacks can grow to
  361.     (effective only if the built-in stack extension method is used).  */
  362.  
  363. #if YYMAXDEPTH == 0
  364. #undef YYMAXDEPTH
  365. #endif
  366.  
  367. #ifndef YYMAXDEPTH
  368. #define YYMAXDEPTH 10000
  369. #endif
  370.  
  371. /* Prevent warning if -Wstrict-prototypes.  */
  372. #ifdef __GNUC__
  373. int yyparse (void);
  374. #endif
  375.  
  376. #if __GNUC__ > 1        /* GNU C and GNU C++ define this.  */
  377. #define __yy_bcopy(FROM,TO,COUNT)    __builtin_memcpy(TO,FROM,COUNT)
  378. #else                /* not GNU C or C++ */
  379. #ifndef __cplusplus
  380.  
  381. /* This is the most reliable way to avoid incompatibilities
  382.    in available built-in functions on various systems.  */
  383. static void
  384. __yy_bcopy (from, to, count)
  385.      char *from;
  386.      char *to;
  387.      int count;
  388. {
  389.   register char *f = from;
  390.   register char *t = to;
  391.   register int i = count;
  392.  
  393.   while (i-- > 0)
  394.     *t++ = *f++;
  395. }
  396.  
  397. #else /* __cplusplus */
  398.  
  399. /* This is the most reliable way to avoid incompatibilities
  400.    in available built-in functions on various systems.  */
  401. static void
  402. __yy_bcopy (char *from, char *to, int count)
  403. {
  404.   register char *f = from;
  405.   register char *t = to;
  406.   register int i = count;
  407.  
  408.   while (i-- > 0)
  409.     *t++ = *f++;
  410. }
  411.  
  412. #endif
  413. #endif
  414.  
  415. #line 184 "/usr/lib/bison.simple"
  416. int
  417. yyparse()
  418. {
  419.   register int yystate;
  420.   register int yyn;
  421.   register short *yyssp;
  422.   register YYSTYPE *yyvsp;
  423.   int yyerrstatus;    /*  number of tokens to shift before error messages enabled */
  424.   int yychar1 = 0;        /*  lookahead token as an internal (translated) token number */
  425.  
  426.   short    yyssa[YYINITDEPTH];    /*  the state stack            */
  427.   YYSTYPE yyvsa[YYINITDEPTH];    /*  the semantic value stack        */
  428.  
  429.   short *yyss = yyssa;        /*  refer to the stacks thru separate pointers */
  430.   YYSTYPE *yyvs = yyvsa;    /*  to allow yyoverflow to reallocate them elsewhere */
  431.  
  432. #ifdef YYLSP_NEEDED
  433.   YYLTYPE yylsa[YYINITDEPTH];    /*  the location stack            */
  434.   YYLTYPE *yyls = yylsa;
  435.   YYLTYPE *yylsp;
  436.  
  437. #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
  438. #else
  439. #define YYPOPSTACK   (yyvsp--, yyssp--)
  440. #endif
  441.  
  442.   int yystacksize = YYINITDEPTH;
  443.  
  444. #ifdef YYPURE
  445.   int yychar;
  446.   YYSTYPE yylval;
  447.   int yynerrs;
  448. #ifdef YYLSP_NEEDED
  449.   YYLTYPE yylloc;
  450. #endif
  451. #endif
  452.  
  453.   YYSTYPE yyval;        /*  the variable used to return        */
  454.                 /*  semantic values from the action    */
  455.                 /*  routines                */
  456.  
  457.   int yylen;
  458.  
  459. #if YYDEBUG != 0
  460.   if (yydebug)
  461.     fprintf(stderr, "Starting parse\n");
  462. #endif
  463.  
  464.   yystate = 0;
  465.   yyerrstatus = 0;
  466.   yynerrs = 0;
  467.   yychar = YYEMPTY;        /* Cause a token to be read.  */
  468.  
  469.   /* Initialize stack pointers.
  470.      Waste one element of value and location stack
  471.      so that they stay on the same level as the state stack.
  472.      The wasted elements are never initialized.  */
  473.  
  474.   yyssp = yyss - 1;
  475.   yyvsp = yyvs;
  476. #ifdef YYLSP_NEEDED
  477.   yylsp = yyls;
  478. #endif
  479.  
  480. /* Push a new state, which is found in  yystate  .  */
  481. /* In all cases, when you get here, the value and location stacks
  482.    have just been pushed. so pushing a state here evens the stacks.  */
  483. yynewstate:
  484.  
  485.   *++yyssp = yystate;
  486.  
  487.   if (yyssp >= yyss + yystacksize - 1)
  488.     {
  489.       /* Give user a chance to reallocate the stack */
  490.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  491.       YYSTYPE *yyvs1 = yyvs;
  492.       short *yyss1 = yyss;
  493. #ifdef YYLSP_NEEDED
  494.       YYLTYPE *yyls1 = yyls;
  495. #endif
  496.  
  497.       /* Get the current used size of the three stacks, in elements.  */
  498.       int size = yyssp - yyss + 1;
  499.  
  500. #ifdef yyoverflow
  501.       /* Each stack pointer address is followed by the size of
  502.      the data in use in that stack, in bytes.  */
  503. #ifdef YYLSP_NEEDED
  504.       /* This used to be a conditional around just the two extra args,
  505.      but that might be undefined if yyoverflow is a macro.  */
  506.       yyoverflow("parser stack overflow",
  507.          &yyss1, size * sizeof (*yyssp),
  508.          &yyvs1, size * sizeof (*yyvsp),
  509.          &yyls1, size * sizeof (*yylsp),
  510.          &yystacksize);
  511. #else
  512.       yyoverflow("parser stack overflow",
  513.          &yyss1, size * sizeof (*yyssp),
  514.          &yyvs1, size * sizeof (*yyvsp),
  515.          &yystacksize);
  516. #endif
  517.  
  518.       yyss = yyss1; yyvs = yyvs1;
  519. #ifdef YYLSP_NEEDED
  520.       yyls = yyls1;
  521. #endif
  522. #else /* no yyoverflow */
  523.       /* Extend the stack our own way.  */
  524.       if (yystacksize >= YYMAXDEPTH)
  525.     {
  526.       yyerror("parser stack overflow");
  527.       return 2;
  528.     }
  529.       yystacksize *= 2;
  530.       if (yystacksize > YYMAXDEPTH)
  531.     yystacksize = YYMAXDEPTH;
  532.       yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
  533.       __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
  534.       yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
  535.       __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
  536. #ifdef YYLSP_NEEDED
  537.       yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
  538.       __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
  539. #endif
  540. #endif /* no yyoverflow */
  541.  
  542.       yyssp = yyss + size - 1;
  543.       yyvsp = yyvs + size - 1;
  544. #ifdef YYLSP_NEEDED
  545.       yylsp = yyls + size - 1;
  546. #endif
  547.  
  548. #if YYDEBUG != 0
  549.       if (yydebug)
  550.     fprintf(stderr, "Stack size increased to %d\n", yystacksize);
  551. #endif
  552.  
  553.       if (yyssp >= yyss + yystacksize - 1)
  554.     YYABORT;
  555.     }
  556.  
  557. #if YYDEBUG != 0
  558.   if (yydebug)
  559.     fprintf(stderr, "Entering state %d\n", yystate);
  560. #endif
  561.  
  562.   goto yybackup;
  563.  yybackup:
  564.  
  565. /* Do appropriate processing given the current state.  */
  566. /* Read a lookahead token if we need one and don't already have one.  */
  567. /* yyresume: */
  568.  
  569.   /* First try to decide what to do without reference to lookahead token.  */
  570.  
  571.   yyn = yypact[yystate];
  572.   if (yyn == YYFLAG)
  573.     goto yydefault;
  574.  
  575.   /* Not known => get a lookahead token if don't already have one.  */
  576.  
  577.   /* yychar is either YYEMPTY or YYEOF
  578.      or a valid token in external form.  */
  579.  
  580.   if (yychar == YYEMPTY)
  581.     {
  582. #if YYDEBUG != 0
  583.       if (yydebug)
  584.     fprintf(stderr, "Reading a token: ");
  585. #endif
  586.       yychar = YYLEX;
  587.     }
  588.  
  589.   /* Convert token to internal form (in yychar1) for indexing tables with */
  590.  
  591.   if (yychar <= 0)        /* This means end of input. */
  592.     {
  593.       yychar1 = 0;
  594.       yychar = YYEOF;        /* Don't call YYLEX any more */
  595.  
  596. #if YYDEBUG != 0
  597.       if (yydebug)
  598.     fprintf(stderr, "Now at end of input.\n");
  599. #endif
  600.     }
  601.   else
  602.     {
  603.       yychar1 = YYTRANSLATE(yychar);
  604.  
  605. #if YYDEBUG != 0
  606.       if (yydebug)
  607.     {
  608.       fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
  609.       /* Give the individual parser a way to print the precise meaning
  610.          of a token, for further debugging info.  */
  611. #ifdef YYPRINT
  612.       YYPRINT (stderr, yychar, yylval);
  613. #endif
  614.       fprintf (stderr, ")\n");
  615.     }
  616. #endif
  617.     }
  618.  
  619.   yyn += yychar1;
  620.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  621.     goto yydefault;
  622.  
  623.   yyn = yytable[yyn];
  624.  
  625.   /* yyn is what to do for this token type in this state.
  626.      Negative => reduce, -yyn is rule number.
  627.      Positive => shift, yyn is new state.
  628.        New state is final state => don't bother to shift,
  629.        just return success.
  630.      0, or most negative number => error.  */
  631.  
  632.   if (yyn < 0)
  633.     {
  634.       if (yyn == YYFLAG)
  635.     goto yyerrlab;
  636.       yyn = -yyn;
  637.       goto yyreduce;
  638.     }
  639.   else if (yyn == 0)
  640.     goto yyerrlab;
  641.  
  642.   if (yyn == YYFINAL)
  643.     YYACCEPT;
  644.  
  645.   /* Shift the lookahead token.  */
  646.  
  647. #if YYDEBUG != 0
  648.   if (yydebug)
  649.     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  650. #endif
  651.  
  652.   /* Discard the token being shifted unless it is eof.  */
  653.   if (yychar != YYEOF)
  654.     yychar = YYEMPTY;
  655.  
  656.   *++yyvsp = yylval;
  657. #ifdef YYLSP_NEEDED
  658.   *++yylsp = yylloc;
  659. #endif
  660.  
  661.   /* count tokens shifted since error; after three, turn off error status.  */
  662.   if (yyerrstatus) yyerrstatus--;
  663.  
  664.   yystate = yyn;
  665.   goto yynewstate;
  666.  
  667. /* Do the default action for the current state.  */
  668. yydefault:
  669.  
  670.   yyn = yydefact[yystate];
  671.   if (yyn == 0)
  672.     goto yyerrlab;
  673.  
  674. /* Do a reduction.  yyn is the number of a rule to reduce with.  */
  675. yyreduce:
  676.   yylen = yyr2[yyn];
  677.   if (yylen > 0)
  678.     yyval = yyvsp[1-yylen]; /* implement default value of the action */
  679.  
  680. #if YYDEBUG != 0
  681.   if (yydebug)
  682.     {
  683.       int i;
  684.  
  685.       fprintf (stderr, "Reducing via rule %d (line %d), ",
  686.            yyn, yyrline[yyn]);
  687.  
  688.       /* Print the symbols being reduced, and their result.  */
  689.       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
  690.     fprintf (stderr, "%s ", yytname[yyrhs[i]]);
  691.       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
  692.     }
  693. #endif
  694.  
  695.  
  696.   switch (yyn) {
  697.  
  698. case 2:
  699. #line 64 "makemfxparser.y"
  700. { ;
  701.     break;}
  702. case 3:
  703. #line 66 "makemfxparser.y"
  704. {
  705.     printf("PARSING typedef struct {\n");
  706.     create_c_files();
  707.     ;
  708.     break;}
  709. case 4:
  710. #line 70 "makemfxparser.y"
  711. {
  712.     printf("} PARSED: %s\n",yyvsp[-1].sstr);
  713.     sprintf(c_struct_name,yyvsp[-1].sstr);
  714.     ;
  715.     break;}
  716. case 5:
  717. #line 74 "makemfxparser.y"
  718. {
  719.     sprintf(c_var_name,yyvsp[-1].sstr);
  720.     printf("\nJust found \"extern %s %s\"; I will use that declaration.\n",
  721.       yyvsp[-2].sstr,yyvsp[-1].sstr);
  722.     ;
  723.     break;}
  724. case 6:
  725. #line 79 "makemfxparser.y"
  726. { ;
  727.     break;}
  728. case 7:
  729. #line 80 "makemfxparser.y"
  730. { ;
  731.     break;}
  732. case 8:
  733. #line 81 "makemfxparser.y"
  734. {
  735.     char sstr[100];
  736.     int ii;
  737.     strcpy(pgmname,yyvsp[0].sstr);
  738.     printf("\nI think \"%s\" is the program you want to execute.\n",pgmname);
  739.  
  740.     sprintf(sstr,"%smfx.c",pgmname); for(ii=0;ii<strlen(sstr);ii++){sstr[ii]=tolower(sstr[ii]);}
  741.     fp_xbc=fopen(sstr,"w"); if (fp_xbc==NULL){puts("ERR: can't write output file!");exit(1);}
  742.     sprintf(sstr,"%smfx.mta",pgmname); for(ii=0;ii<strlen(sstr);ii++){sstr[ii]=tolower(sstr[ii]);}
  743.     fp_xbm=fopen(sstr,"w"); if (fp_xbm==NULL){puts("ERR: can't write output file!");exit(1);}
  744.     sprintf(sstr,"%swdw.mta",pgmname); for(ii=0;ii<strlen(sstr);ii++){sstr[ii]=tolower(sstr[ii]);}
  745.     fp_wdw=fopen(sstr,"w"); if (fp_wdw==NULL){puts("ERR: can't write output file!");exit(1);}
  746.  
  747.     fprintf(fp_wdw,"Malloc(300); @start( (\"%s\") (\"bw\") );\n",pgmname);
  748.     fprintf(fp_wdw,"@%smfx();            %% Read MFX Group Definitions\n",pgmname);
  749.     ;
  750.     break;}
  751. case 9:
  752. #line 97 "makemfxparser.y"
  753. { puts("Found MFX Data Initialization..."); ;
  754.     break;}
  755. case 10:
  756. #line 98 "makemfxparser.y"
  757. {
  758.     puts("End of MFX Data Initialization");
  759.     write_c_files(c_var_name,pgmname);
  760.     ;
  761.     break;}
  762. case 11:
  763. #line 102 "makemfxparser.y"
  764. {
  765.     /*{{{  */
  766.     fprintf(fp_dmfx,"i( (\"%s\") 0 );\n",yyvsp[-1].sstr);
  767.     obj++;
  768.     fprintf(fp_dwdw,"o( $WDW,(\"%02dt\") S . 1 %d 8 1 Remark);bg( $WDW,(\"%02dt\") . (\"%s\") ); eg(); %% Description\n",obj,obj,obj,yyvsp[-1].sstr);
  769.     fprintf(fp_dwdw,"o( $WDW,(\"%02d\") I I 9 %d 8 1 Standard);bg( $WDW,(\"%02d\") . (ptr)MFX:$MFX.%s ); %% Integer Object\n",obj,obj,obj,yyvsp[-1].sstr);
  770.     fprintf(fp_dwdw,"  cn(epO $WDW,(\"%02d\") );",obj-1);
  771.     fprintf(fp_dwdw,"cn(edO $WDW,(\"%02d\") );eg(); \n",obj+1);
  772.     fprintf(fp_wmfx,"XbWMFX_PutInteger(&thestruct.%s,\"%s\");\n",yyvsp[-1].sstr,yyvsp[-1].sstr);
  773.     fprintf(fp_rmfx,"if(XbWMFX_GetInteger(&thestruct.%s)){goto error;}\n",yyvsp[-1].sstr);
  774.     printf("short %s\n",yyvsp[-1].sstr);
  775.     ;
  776.     break;}
  777. case 12:
  778. #line 115 "makemfxparser.y"
  779. {
  780.     /*{{{  */
  781.     { int ii, no;
  782.       no=atoi(yyvsp[-2].sstr);
  783.       for (ii=0;ii<no;ii++){
  784.         fprintf(fp_dmfx,"i( (\"%s[%d]\") 0);\n",yyvsp[-4].sstr,ii);
  785.         fprintf(fp_wmfx,"XbWMFX_PutInteger(&thestruct.%s[%d],\"%s[%d]\");\n",yyvsp[-4].sstr,ii,yyvsp[-4].sstr,ii);
  786.         fprintf(fp_rmfx,"if(XbWMFX_GetInteger(&thestruct.%s[%d])){goto error;}\n",yyvsp[-4].sstr,ii);
  787.         }
  788.       printf("integer %s[%s]\n",yyvsp[-4].sstr,yyvsp[-2].sstr);
  789.       }
  790.     ;
  791.     break;}
  792. case 13:
  793. #line 128 "makemfxparser.y"
  794. {
  795.     /*{{{  */
  796.     { int ii,jj, nox,noy;
  797.       nox=atoi(yyvsp[-5].sstr);
  798.       noy=atoi(yyvsp[-2].sstr);
  799.       for (ii=0;ii<nox;ii++){
  800.         for (jj=0;jj<noy;jj++){
  801.           fprintf(fp_dmfx,"i( (\"%s[%d][%d]\") 0);\n",yyvsp[-7].sstr,ii,jj);
  802.           fprintf(fp_wmfx,"XbWMFX_PutInteger(&thestruct.%s[%d][%d],\"%s[%d][%d]\");\n",yyvsp[-7].sstr,ii,jj,yyvsp[-7].sstr,ii,jj);
  803.           fprintf(fp_rmfx,"if(XbWMFX_GetInteger(&thestruct.%s[%d][%d])){goto error;}\n",yyvsp[-7].sstr,ii,jj);
  804.           }
  805.         }
  806.       printf("integer %s[%s][%s]\n",yyvsp[-7].sstr,yyvsp[-5].sstr,yyvsp[-2].sstr);
  807.       }
  808.     ;
  809.     break;}
  810. case 14:
  811. #line 144 "makemfxparser.y"
  812. {
  813.     /*{{{  */
  814.     { int ii,jj,kk, nox,noy,noz;
  815.       nox=atoi(yyvsp[-8].sstr);
  816.       noy=atoi(yyvsp[-5].sstr);
  817.       noz=atoi(yyvsp[-2].sstr);
  818.       for (ii=0;ii<nox;ii++){
  819.         for (jj=0;jj<noy;jj++){
  820.           for (kk=0;kk<noz;kk++){
  821.             fprintf(fp_dmfx,"i( (\"%s[%d][%d][%d]\") 0);\n",yyvsp[-10].sstr,ii,jj,kk);
  822.             fprintf(fp_wmfx,"XbWMFX_PutInteger(&thestruct.%s[%d][%d][%d],\"%s[%d][%d][%d]\");\n",yyvsp[-10].sstr,ii,jj,kk,yyvsp[-10].sstr,ii,jj,kk);
  823.             fprintf(fp_rmfx,"if(XbWMFX_GetInteger(&thestruct.%s[%d][%d][%d])){goto error;}\n",yyvsp[-10].sstr,ii,jj,kk);
  824.             }
  825.           }
  826.         }
  827.       printf("integer %s[%s][%s][%s]\n",yyvsp[-10].sstr,yyvsp[-8].sstr,yyvsp[-5].sstr,yyvsp[-2].sstr);
  828.       }
  829.     ;
  830.     break;}
  831. case 15:
  832. #line 163 "makemfxparser.y"
  833. {
  834.     /*{{{  */
  835.     fprintf(fp_dmfx,"d( (\"%s\") 0.0000001);\n",yyvsp[-1].sstr);
  836.     obj++;
  837.     fprintf(fp_dwdw,"o( $WDW,(\"%02dt\") S . 1 %d 8 1 Remark);bg( $WDW,(\"%02dt\") . (\"%s\") ); eg(); %% Description\n",obj,obj,obj,yyvsp[-1].sstr);
  838.     fprintf(fp_dwdw,"o( $WDW,(\"%02d\") S . 9 %d 15 1 Standard);  %% Double Float Object\n",obj,obj);
  839.     fprintf(fp_dwdw,"bg( $WDW,(\"%02d\") . (ptr)MFX:$MFX.%s );  %% Object Head\n",obj,yyvsp[-1].sstr);
  840.     fprintf(fp_dwdw,"  ff( (\"%%14.7f\") (\"\") 1 );\n          %% Object Body with Display Format\n");
  841.     fprintf(fp_dwdw,"  cn(epO $WDW,(\"%02d\") );",obj-1);
  842.     fprintf(fp_dwdw,"cn(edO $WDW,(\"%02d\") );eg(); \n",obj+1);
  843.     fprintf(fp_wmfx,"XbWMFX_PutDouble(&thestruct.%s,\"%s\");\n",yyvsp[-1].sstr,yyvsp[-1].sstr);
  844.     fprintf(fp_rmfx,"if(XbWMFX_GetDouble(&thestruct.%s)){goto error;}\n",yyvsp[-1].sstr);
  845.     printf("double %s\n",yyvsp[-1].sstr);
  846.     ;
  847.     break;}
  848. case 16:
  849. #line 178 "makemfxparser.y"
  850. {
  851.     /*{{{  */
  852.     { int ii, no;
  853.       no=atoi(yyvsp[-2].sstr);
  854.       for (ii=0;ii<no;ii++){
  855.         fprintf(fp_dmfx,"d( (\"%s[%d]\") 0.0000001 );\n",yyvsp[-4].sstr,ii);
  856.         fprintf(fp_wmfx,"XbWMFX_PutDouble(&thestruct.%s[%d],\"%s[%d]\");\n",yyvsp[-4].sstr,ii,yyvsp[-4].sstr,ii);
  857.         fprintf(fp_rmfx,"if(XbWMFX_GetDouble(&thestruct.%s[%d])){goto error;}\n",yyvsp[-4].sstr,ii);
  858.         }
  859.       printf("double %s[%s]\n",yyvsp[-4].sstr,yyvsp[-2].sstr);
  860.       }
  861.     ;
  862.     break;}
  863. case 17:
  864. #line 191 "makemfxparser.y"
  865. {
  866.     /*{{{  */
  867.     { int ii,jj, nox,noy;
  868.       nox=atoi(yyvsp[-5].sstr);
  869.       noy=atoi(yyvsp[-2].sstr);
  870.       for (ii=0;ii<nox;ii++){
  871.         for (jj=0;jj<noy;jj++){
  872.           fprintf(fp_dmfx,"d( (\"%s[%d][%d]\") 0.0000001 );\n",yyvsp[-7].sstr,ii,jj);
  873.           fprintf(fp_wmfx,"XbWMFX_PutDouble(&thestruct.%s[%d][%d],\"%s[%d][%d]\");\n",yyvsp[-7].sstr,ii,jj,yyvsp[-7].sstr,ii,jj);
  874.           fprintf(fp_rmfx,"if(XbWMFX_GetDouble(&thestruct.%s[%d][%d])){goto error;}\n",yyvsp[-7].sstr,ii,jj);
  875.           }
  876.         }
  877.       printf("double %s[%s][%s]\n",yyvsp[-7].sstr,yyvsp[-5].sstr,yyvsp[-2].sstr);
  878.       }
  879.     ;
  880.     break;}
  881. case 18:
  882. #line 207 "makemfxparser.y"
  883. {
  884.     /*{{{  */
  885.     { int ii,jj,kk, nox,noy,noz;
  886.       nox=atoi(yyvsp[-8].sstr);
  887.       noy=atoi(yyvsp[-5].sstr);
  888.       noz=atoi(yyvsp[-2].sstr);
  889.       for (ii=0;ii<nox;ii++){
  890.         for (jj=0;jj<noy;jj++){
  891.           for (kk=0;kk<noz;kk++){
  892.             fprintf(fp_dmfx,"d( (\"%s[%d][%d][%d]\") 0.0000001 );\n",yyvsp[-10].sstr,ii,jj,kk);
  893.             fprintf(fp_wmfx,"XbWMFX_PutDouble(&thestruct.%s[%d][%d][%d],\"%s[%d][%d][%d]\");\n",yyvsp[-10].sstr,ii,jj,kk,yyvsp[-10].sstr,ii,jj,kk);
  894.             fprintf(fp_rmfx,"if(XbWMFX_GetDouble(&thestruct.%s[%d][%d][%d])){goto error;}\n",yyvsp[-10].sstr,ii,jj,kk);
  895.             }
  896.           }
  897.         }
  898.       printf("double %s[%s][%s][%s]\n",yyvsp[-10].sstr,yyvsp[-8].sstr,yyvsp[-5].sstr,yyvsp[-2].sstr);
  899.       }
  900.     ;
  901.     break;}
  902. case 19:
  903. #line 226 "makemfxparser.y"
  904. {
  905.     /*{{{  */
  906.     fprintf(fp_dmfx,"s( (\"%s\") %s (\" \") );\n",yyvsp[-4].sstr,yyvsp[-2].sstr);
  907.     obj++;
  908.     fprintf(fp_dwdw,"o( $WDW,(\"%02dt\") S . 1 %d 8 1 Remark);bg( $WDW,(\"%02dt\") . (\"%s\") ); eg(); %% Description\n",obj,obj,obj,yyvsp[-4].sstr);
  909.     fprintf(fp_dwdw,"o( $WDW,(\"%02d\") S S 9 %d 40 1 Standard);bg( $WDW,(\"%02d\") . (ptr)MFX:$MFX.%s );       %% String Object\n",obj,obj,obj,yyvsp[-4].sstr);
  910.     fprintf(fp_dwdw,"  cn(epO $WDW,(\"%02d\") );",obj-1);
  911.     fprintf(fp_dwdw,"cn(edO $WDW,(\"%02d\") );eg(); \n",obj+1);
  912.     fprintf(fp_wmfx,"XbWMFX_PutString(thestruct.%s,\"%s\");\n",yyvsp[-4].sstr,yyvsp[-4].sstr);
  913.     fprintf(fp_rmfx,"if(XbWMFX_GetString(thestruct.%s)){goto error;}\n",yyvsp[-4].sstr);
  914.     printf("string %s\n",yyvsp[-4].sstr);
  915.     ;
  916.     break;}
  917. case 20:
  918. #line 239 "makemfxparser.y"
  919. {
  920.     /*{{{  */
  921.     { int ii, nox;
  922.       nox=atoi(yyvsp[-5].sstr);
  923.       for (ii=0;ii<nox;ii++){
  924.         fprintf(fp_dmfx,"s( (\"%s[%d]\") %s (\" \") );\n",yyvsp[-7].sstr,ii,yyvsp[-5].sstr);
  925.         fprintf(fp_wmfx,"XbWMFX_PutString(&thestruct.%s[%d][0],\"%s[%d]\");\n",yyvsp[-7].sstr,ii,yyvsp[-7].sstr,ii);
  926.         fprintf(fp_rmfx,"if(XbWMFX_GetString(&thestruct.%s[%d][0])){goto error;}\n",yyvsp[-7].sstr,ii);
  927.         }
  928.       printf("string %s[%s]\n",yyvsp[-7].sstr,yyvsp[-5].sstr);
  929.       }
  930.     ;
  931.     break;}
  932. case 21:
  933. #line 252 "makemfxparser.y"
  934. {
  935.     /*{{{  */
  936.     fprintf(fp_dmfx,"i( (\"%s\") 0 );\n",yyvsp[-1].sstr);
  937.     obj++;
  938.     fprintf(fp_dwdw,"o( $WDW,(\"%02dt\") S . 1 %d 8 1 Remark);bg( $WDW,(\"%02dt\") . (\"%s\") ); eg(); %% Description\n",obj,obj,obj,yyvsp[-1].sstr);
  939.     fprintf(fp_dwdw,"o( $WDW,(\"%02d\") I I 9 %d 8 1 Standard);bg( $WDW,(\"%02d\") . (ptr)MFX:$MFX.%s );  %% Integer Object\n",obj,obj,obj,yyvsp[-1].sstr);
  940.     fprintf(fp_dwdw,"  cn(epO $WDW,(\"%02d\") );",obj-1);
  941.     fprintf(fp_dwdw,"cn(edO $WDW,(\"%02d\") );eg(); \n",obj+1);
  942.     fprintf(fp_wmfx,"XbWMFX_PutShort(&thestruct.%s,\"%s\");\n",yyvsp[-1].sstr,yyvsp[-1].sstr);
  943.     fprintf(fp_rmfx,"if(XbWMFX_GetShort(&thestruct.%s)){goto error;}\n",yyvsp[-1].sstr);
  944.     printf("short %s\n",yyvsp[-1].sstr);
  945.     ;
  946.     break;}
  947. case 22:
  948. #line 265 "makemfxparser.y"
  949. {
  950.     /*{{{  */
  951.     { int ii, no;
  952.       no=atoi(yyvsp[-2].sstr);
  953.       for (ii=0;ii<no;ii++){
  954.         fprintf(fp_dmfx,"i( (\"%s[%d]\") 0);\n",yyvsp[-4].sstr,ii);
  955.         fprintf(fp_wmfx,"XbWMFX_PutShort(&thestruct.%s[%d],\"%s[%d]\");\n",yyvsp[-4].sstr,ii,yyvsp[-4].sstr,ii);
  956.         fprintf(fp_rmfx,"if(XbWMFX_GetShort(&thestruct.%s[%d])){goto error;}\n",yyvsp[-4].sstr,ii);
  957.         }
  958.       printf("short %s[%s]\n",yyvsp[-4].sstr,yyvsp[-2].sstr);
  959.       }
  960.     ;
  961.     break;}
  962. case 23:
  963. #line 278 "makemfxparser.y"
  964. {
  965.     /*{{{  */
  966.     { int ii,jj, nox,noy;
  967.       nox=atoi(yyvsp[-5].sstr);
  968.       noy=atoi(yyvsp[-2].sstr);
  969.       for (ii=0;ii<nox;ii++){
  970.         for (jj=0;jj<noy;jj++){
  971.           fprintf(fp_dmfx,"i( (\"%s[%d][%d]\") 0);\n",yyvsp[-7].sstr,ii,jj);
  972.           fprintf(fp_wmfx,"XbWMFX_PutShort(&thestruct.%s[%d][%d],\"%s[%d][%d]\");\n",yyvsp[-7].sstr,ii,jj,yyvsp[-7].sstr,ii,jj);
  973.           fprintf(fp_rmfx,"if(XbWMFX_GetShort(&thestruct.%s[%d][%d])){goto error;}\n",yyvsp[-7].sstr,ii,jj);
  974.           }
  975.         }
  976.       printf("short %s[%s][%s]\n",yyvsp[-7].sstr,yyvsp[-5].sstr,yyvsp[-2].sstr);
  977.       }
  978.     ;
  979.     break;}
  980. case 24:
  981. #line 294 "makemfxparser.y"
  982. {
  983.     /*{{{  */
  984.     { int ii,jj,kk, nox,noy,noz;
  985.       nox=atoi(yyvsp[-8].sstr);
  986.       noy=atoi(yyvsp[-5].sstr);
  987.       noz=atoi(yyvsp[-2].sstr);
  988.       for (ii=0;ii<nox;ii++){
  989.         for (jj=0;jj<noy;jj++){
  990.           for (kk=0;kk<noz;kk++){
  991.             fprintf(fp_dmfx,"i( (\"%s[%d][%d][%d]\") 0);\n",yyvsp[-10].sstr,ii,jj,kk);
  992.             fprintf(fp_wmfx,"XbWMFX_PutShort(&thestruct.%s[%d][%d][%d],\"%s[%d][%d][%d]\");\n",yyvsp[-10].sstr,ii,jj,kk,yyvsp[-10].sstr,ii,jj,kk);
  993.             fprintf(fp_rmfx,"if(XbWMFX_GetShort(&thestruct.%s[%d][%d][%d])){goto error;}\n",yyvsp[-10].sstr,ii,jj,kk);
  994.             }
  995.           }
  996.         }
  997.       printf("short %s[%s][%s][%s]\n",yyvsp[-10].sstr,yyvsp[-8].sstr,yyvsp[-5].sstr,yyvsp[-2].sstr);
  998.       }
  999.     ;
  1000.     break;}
  1001. }
  1002.    /* the action file gets copied in in place of this dollarsign */
  1003. #line 465 "/usr/lib/bison.simple"
  1004.  
  1005.   yyvsp -= yylen;
  1006.   yyssp -= yylen;
  1007. #ifdef YYLSP_NEEDED
  1008.   yylsp -= yylen;
  1009. #endif
  1010.  
  1011. #if YYDEBUG != 0
  1012.   if (yydebug)
  1013.     {
  1014.       short *ssp1 = yyss - 1;
  1015.       fprintf (stderr, "state stack now");
  1016.       while (ssp1 != yyssp)
  1017.     fprintf (stderr, " %d", *++ssp1);
  1018.       fprintf (stderr, "\n");
  1019.     }
  1020. #endif
  1021.  
  1022.   *++yyvsp = yyval;
  1023.  
  1024. #ifdef YYLSP_NEEDED
  1025.   yylsp++;
  1026.   if (yylen == 0)
  1027.     {
  1028.       yylsp->first_line = yylloc.first_line;
  1029.       yylsp->first_column = yylloc.first_column;
  1030.       yylsp->last_line = (yylsp-1)->last_line;
  1031.       yylsp->last_column = (yylsp-1)->last_column;
  1032.       yylsp->text = 0;
  1033.     }
  1034.   else
  1035.     {
  1036.       yylsp->last_line = (yylsp+yylen-1)->last_line;
  1037.       yylsp->last_column = (yylsp+yylen-1)->last_column;
  1038.     }
  1039. #endif
  1040.  
  1041.   /* Now "shift" the result of the reduction.
  1042.      Determine what state that goes to,
  1043.      based on the state we popped back to
  1044.      and the rule number reduced by.  */
  1045.  
  1046.   yyn = yyr1[yyn];
  1047.  
  1048.   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  1049.   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  1050.     yystate = yytable[yystate];
  1051.   else
  1052.     yystate = yydefgoto[yyn - YYNTBASE];
  1053.  
  1054.   goto yynewstate;
  1055.  
  1056. yyerrlab:   /* here on detecting error */
  1057.  
  1058.   if (! yyerrstatus)
  1059.     /* If not already recovering from an error, report this error.  */
  1060.     {
  1061.       ++yynerrs;
  1062.  
  1063. #ifdef YYERROR_VERBOSE
  1064.       yyn = yypact[yystate];
  1065.  
  1066.       if (yyn > YYFLAG && yyn < YYLAST)
  1067.     {
  1068.       int size = 0;
  1069.       char *msg;
  1070.       int x, count;
  1071.  
  1072.       count = 0;
  1073.       /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
  1074.       for (x = (yyn < 0 ? -yyn : 0);
  1075.            x < (sizeof(yytname) / sizeof(char *)); x++)
  1076.         if (yycheck[x + yyn] == x)
  1077.           size += strlen(yytname[x]) + 15, count++;
  1078.       msg = (char *) malloc(size + 15);
  1079.       if (msg != 0)
  1080.         {
  1081.           strcpy(msg, "parse error");
  1082.  
  1083.           if (count < 5)
  1084.         {
  1085.           count = 0;
  1086.           for (x = (yyn < 0 ? -yyn : 0);
  1087.                x < (sizeof(yytname) / sizeof(char *)); x++)
  1088.             if (yycheck[x + yyn] == x)
  1089.               {
  1090.             strcat(msg, count == 0 ? ", expecting `" : " or `");
  1091.             strcat(msg, yytname[x]);
  1092.             strcat(msg, "'");
  1093.             count++;
  1094.               }
  1095.         }
  1096.           yyerror(msg);
  1097.           free(msg);
  1098.         }
  1099.       else
  1100.         yyerror ("parse error; also virtual memory exceeded");
  1101.     }
  1102.       else
  1103. #endif /* YYERROR_VERBOSE */
  1104.     yyerror("parse error");
  1105.     }
  1106.  
  1107.   goto yyerrlab1;
  1108. yyerrlab1:   /* here on error raised explicitly by an action */
  1109.  
  1110.   if (yyerrstatus == 3)
  1111.     {
  1112.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  1113.  
  1114.       /* return failure if at end of input */
  1115.       if (yychar == YYEOF)
  1116.     YYABORT;
  1117.  
  1118. #if YYDEBUG != 0
  1119.       if (yydebug)
  1120.     fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  1121. #endif
  1122.  
  1123.       yychar = YYEMPTY;
  1124.     }
  1125.  
  1126.   /* Else will try to reuse lookahead token
  1127.      after shifting the error token.  */
  1128.  
  1129.   yyerrstatus = 3;        /* Each real token shifted decrements this */
  1130.  
  1131.   goto yyerrhandle;
  1132.  
  1133. yyerrdefault:  /* current state does not do anything special for the error token. */
  1134.  
  1135. #if 0
  1136.   /* This is wrong; only states that explicitly want error tokens
  1137.      should shift them.  */
  1138.   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  1139.   if (yyn) goto yydefault;
  1140. #endif
  1141.  
  1142. yyerrpop:   /* pop the current state because it cannot handle the error token */
  1143.  
  1144.   if (yyssp == yyss) YYABORT;
  1145.   yyvsp--;
  1146.   yystate = *--yyssp;
  1147. #ifdef YYLSP_NEEDED
  1148.   yylsp--;
  1149. #endif
  1150.  
  1151. #if YYDEBUG != 0
  1152.   if (yydebug)
  1153.     {
  1154.       short *ssp1 = yyss - 1;
  1155.       fprintf (stderr, "Error: state stack now");
  1156.       while (ssp1 != yyssp)
  1157.     fprintf (stderr, " %d", *++ssp1);
  1158.       fprintf (stderr, "\n");
  1159.     }
  1160. #endif
  1161.  
  1162. yyerrhandle:
  1163.  
  1164.   yyn = yypact[yystate];
  1165.   if (yyn == YYFLAG)
  1166.     goto yyerrdefault;
  1167.  
  1168.   yyn += YYTERROR;
  1169.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  1170.     goto yyerrdefault;
  1171.  
  1172.   yyn = yytable[yyn];
  1173.   if (yyn < 0)
  1174.     {
  1175.       if (yyn == YYFLAG)
  1176.     goto yyerrpop;
  1177.       yyn = -yyn;
  1178.       goto yyreduce;
  1179.     }
  1180.   else if (yyn == 0)
  1181.     goto yyerrpop;
  1182.  
  1183.   if (yyn == YYFINAL)
  1184.     YYACCEPT;
  1185.  
  1186. #if YYDEBUG != 0
  1187.   if (yydebug)
  1188.     fprintf(stderr, "Shifting error token, ");
  1189. #endif
  1190.  
  1191.   *++yyvsp = yylval;
  1192. #ifdef YYLSP_NEEDED
  1193.   *++yylsp = yylloc;
  1194. #endif
  1195.  
  1196.   yystate = yyn;
  1197.   goto yynewstate;
  1198. }
  1199. #line 314 "makemfxparser.y"
  1200.  
  1201.  
  1202. int put_lval_number(char *sst){strcpy(yylval.sstr,sst);      return(NUMBER); }
  1203. int put_lval_name(char *sst){  strcpy(yylval.sstr,sst);      return(NAME);   }
  1204. int put_lval_integer(void){    strcpy(yylval.sstr,"int");    return(INT);    }
  1205. int put_lval_double(void){     strcpy(yylval.sstr,"double"); return(DOUBLE); }
  1206. int put_lval_string(void){     strcpy(yylval.sstr,"char");   return(STRING); }
  1207. int put_lval_short(void){      strcpy(yylval.sstr,"short");  return(SHORT);  }
  1208. int put_lval_typedef(void){    strcpy(yylval.sstr,"typedef");return(TYPEDEF);}
  1209. int put_lval_struct(void){     strcpy(yylval.sstr,"struct"); return(STRUCT); }
  1210. int put_lval_extern(void){     strcpy(yylval.sstr,"extern"); return(EXTERN); }
  1211. int put_lval_define(void){     strcpy(yylval.sstr,"define"); return(DEFINE); }
  1212. int put_lval_ifdef(void){      strcpy(yylval.sstr,"ifdef");  return(IFDEF);  }
  1213. int put_lval_endif(void){      strcpy(yylval.sstr,"endif");  return(ENDIF);  }
  1214. int put_lval_pgmname(void){    strcpy(yylval.sstr,"pgmname");return(PGMNAME);}
  1215. int put_lval_mfxinit(void){    strcpy(yylval.sstr,"mfxinit");return(MFXINIT);}
  1216.  
  1217.  
  1218. void create_c_files(void){
  1219.   c_var_name[0]=0;
  1220.   obj=4;
  1221.   fp_wmfx=fopen("makemfx.wmfx","w"); if (fp_wmfx==NULL){puts("ERR: can't write scratch file!");exit(1);}
  1222.   fp_rmfx=fopen("makemfx.rmfx","w"); if (fp_rmfx==NULL){puts("ERR: can't write scratch file!");exit(1);}
  1223.   fp_dmfx=fopen("makemfx.dmfx","w"); if (fp_dmfx==NULL){puts("ERR: can't write scratch file!");exit(1);}
  1224.   fp_dwdw=fopen("makemfx.dwdw","w"); if (fp_dwdw==NULL){puts("ERR: can't write scratch file!");exit(1);}
  1225.   }
  1226.  
  1227. int write_c_files(char *s, char *pgm){
  1228.   char sstr[100];
  1229.   int ii;
  1230.  
  1231.   fclose(fp_dmfx);
  1232.   fclose(fp_rmfx);
  1233.   fclose(fp_wmfx);
  1234.   fclose(fp_dwdw);
  1235.  
  1236.   system("cp /xw/xbmfx/* .");
  1237.   fprintf(fp_xbc,"/*  XbW MetaFile eXchange (Interface to Applications): XBMFX  */\n");
  1238.  
  1239.   if (!struct_defined){
  1240.     struct_defined = 1;
  1241.     fprintf(fp_xbc,"\n#ifdef ALREADY_DEFINED_MFX_%s /* Schon #defined ? */\n",s);
  1242.     fprintf(fp_xbc,"\n#else \n");
  1243.     fprintf(fp_xbc,"\n#define ALREADY_DEFINED_MFX_%s 1 \n",s);
  1244.     fprintf(fp_xbc,"\n#ifndef ProgramName /* Extra Module */\n");
  1245.     fprintf(fp_xbc,"#include <stdlib.h>\n");
  1246.     fprintf(fp_xbc,"#include <stdio.h>\n");
  1247.     fprintf(fp_xbc,"#include <string.h>\n");
  1248.     fprintf(fp_xbc,"#define MFX_INIT 1\n");
  1249.     fprintf(fp_xbc,"#include \"xbmfx.h\"\n");
  1250.     fprintf(fp_xbc,"#include \"%smfx.h\"\n",pgm);
  1251.     fprintf(fp_xbc,"\n#endif /*ProgramName*/\n");
  1252.     }
  1253.  
  1254.   fprintf(fp_xbc,"\n#ifdef thestruct\n");
  1255.   fprintf(fp_xbc,"#undef thestruct\n");
  1256.   fprintf(fp_xbc,"#endif\n");
  1257.  
  1258.   if (!c_var_name[0]){
  1259.     fprintf(fp_xbc,"#define thestruct MFX_%s\n\n",s);
  1260.     fprintf(fp_xbc,"%s MFX_%s;\n\n",s,s);
  1261.   } else {
  1262.     fprintf(fp_xbc,"#define thestruct %s\n\n",c_var_name);
  1263.     }
  1264.  
  1265.   fprintf(fp_xbc,"int WriteMFXGroup_%s(char*filename, char*dataset, char *mode){\n",c_var_name);
  1266.   /*{{{  */
  1267.   fprintf(fp_xbc,"  if (filename == NULL) { filename = \"%s.mfx\"; } \n",c_var_name);
  1268.   fprintf(fp_xbc,"  if (dataset == NULL) { dataset = \"%s\"; }\n",s);
  1269.   fprintf(fp_xbc,"  if (mode == NULL) { mode = \"w\"; }\n");
  1270.   fprintf(fp_xbc,"  if (XbWMFX_WriteSet(filename,dataset,mode)) {\n");
  1271.   fprintf(fp_xbc,"    return(1);\n");
  1272.   fprintf(fp_xbc,"    }\n");
  1273.   {
  1274.     char li[1000];
  1275.     fp_wmfx=fopen("makemfx.wmfx","r");
  1276.     if (fp_wmfx==NULL){puts("ERR: can't read scratch file!");exit(1);}
  1277.     while(!feof(fp_wmfx)){
  1278.       if (fgets(li,1000,fp_wmfx)){
  1279.         fputs(li,fp_xbc);
  1280.         }
  1281.       }
  1282.     }
  1283.   
  1284.   fclose(fp_wmfx);
  1285.   unlink("makemfx.wmfx");
  1286.   
  1287.   fprintf(fp_xbc,"  XbWMFX_WriteEnd();\n");
  1288.   fprintf(fp_xbc,"  XbWMFX_CloseSet();\n");
  1289.   fprintf(fp_xbc,"  return(0);\n");
  1290.   fprintf(fp_xbc,"  }\n\n");
  1291.   
  1292.   /*}}}  */
  1293.   fprintf(fp_xbc,"int ReadMFXGroup_%s(char*filename, char*dataset){\n",c_var_name);
  1294.   /*{{{  */
  1295.   fprintf(fp_xbc,"  if (filename == NULL) { filename = \"%s.mfx\"; } \n",c_var_name);
  1296.   fprintf(fp_xbc,"  if (dataset == NULL) { dataset = \"%s\"; }\n",s);
  1297.   fprintf(fp_xbc,"  if (XbWMFX_ReadSet(filename,dataset)) {\n");
  1298.   fprintf(fp_xbc,"    puts(\"ERR on opening MFX file; I will now try to append\");\n");
  1299.   fprintf(fp_xbc,"    ropenerr:;\n");
  1300.   fprintf(fp_xbc,"    printf(\"a working MFX Group %%s to the end of file %%s...\\n\",dataset,filename);\n");
  1301.   fprintf(fp_xbc,"    if (!WriteMFXGroup_%s(filename,dataset,\"a\")){\n",c_var_name);
  1302.   fprintf(fp_xbc,"      puts(\"...done. Exiting with error code.\");\n");
  1303.   fprintf(fp_xbc,"      printf(\"The end of file %%s should now be readable. Please check its contents!\\n\",filename);\n");
  1304.   fprintf(fp_xbc,"      printf(\"If %%s did not exist until now, don't get crazy :)\\n\",filename);\n");
  1305.   fprintf(fp_xbc,"      return(1);\n");
  1306.   fprintf(fp_xbc,"      }\n");
  1307.   fprintf(fp_xbc,"    else {\n");
  1308.   fprintf(fp_xbc,"      puts(\"...did not work. Exiting with error code.\");\n");
  1309.   fprintf(fp_xbc,"      printf(\"I must now overwrite your file %%s, sorry. Please check its contents!\\n\",filename);\n");
  1310.   fprintf(fp_xbc,"      WriteMFXGroup_%s(filename,dataset,\"w\");\n",c_var_name);
  1311.   fprintf(fp_xbc,"      printf(\"If %%s did not exist until now, don't get crazy :)\\n\",filename);\n");
  1312.   fprintf(fp_xbc,"      return(1);\n");
  1313.   fprintf(fp_xbc,"      }\n");
  1314.   fprintf(fp_xbc,"    }\n");
  1315.   {
  1316.     char li[1000];
  1317.     fp_rmfx=fopen("makemfx.rmfx","r");
  1318.     if (fp_rmfx==NULL){puts("ERR: can't read scratch file!");exit(1);}
  1319.     while(!feof(fp_rmfx)){
  1320.       if (fgets(li,1000,fp_rmfx)>0){
  1321.         fputs(li,fp_xbc);
  1322.         }
  1323.       }
  1324.     }
  1325.   
  1326.   fprintf(fp_xbc,"  XbWMFX_CloseSet();\n");
  1327.   fprintf(fp_xbc,"  return(0);\n");
  1328.   fprintf(fp_xbc,"error:;\n");
  1329.   fprintf(fp_xbc,"  printf(\"Error while reading MFX Group %s\\n\");",c_var_name);
  1330.   fprintf(fp_xbc,"  XbWMFX_CloseSet();\n");
  1331.   fprintf(fp_xbc,"  puts(\"I will now try to append\");\n");
  1332.   fprintf(fp_xbc,"  goto ropenerr;\n");
  1333.   fprintf(fp_xbc,"  }\n\n\n");
  1334.   
  1335.   fclose(fp_rmfx);
  1336.   unlink("makemfx.rmfx");
  1337.   
  1338.   /*}}}  */
  1339.   fprintf(fp_xbc,"\n#undef thestruct\n");
  1340.  
  1341.   fprintf(fp_xbm," %% XbW MFX Group %s\n",s);
  1342.   /*{{{  */
  1343.   sprintf(sstr,"%s",s); for(ii=0;ii<strlen(sstr);ii++){sstr[ii]=tolower(sstr[ii]);}
  1344.   fprintf(fp_xbm,"@mfxgroup/begin( %s (\"%s.mfx\") (\"xbwmfx.\") );\n",s,sstr);
  1345.   {
  1346.     char li[1000];
  1347.     fp_dmfx=fopen("makemfx.dmfx","r");
  1348.     if (fp_dmfx==NULL){puts("ERR: can't read scratch file!");exit(1);}
  1349.     while(!feof(fp_dmfx)){
  1350.       if(fgets(li,1000,fp_dmfx)){
  1351.         fputs(li,fp_xbm);
  1352.         }
  1353.       }
  1354.     }
  1355.   fclose(fp_dmfx);
  1356.   unlink("makemfx.dmfx");
  1357.   
  1358.   fprintf(fp_xbm,"@mfxgroup/end();\n\n");
  1359.   
  1360.   /*}}}  */
  1361.   fprintf(fp_trl,"MFXGroup( Read %s );\n",s);
  1362.  
  1363.   /* write window */
  1364.   /*{{{  */
  1365.   {
  1366.     char wdwname[4];
  1367.     char li[1000];
  1368.     wdwnr++;
  1369.     sprintf(wdwname,"WD%02d",wdwnr);
  1370.     fprintf(fp_wdw," %% XbW Window definition for MFX Group %s\n",c_var_name);
  1371.     fprintf(fp_wdw,"wdw( %s %d %d 60 40 StandardWDW );     %% Get a Window\n",wdwname,wdwnr,wdwnr);
  1372.     fprintf(fp_wdw,"@window/gimmicks( (\"%s\") (\" Program '%s' Test-Window '%s' (P) by XbW\") );  %% Get some buttons\n",wdwname,pgmname,wdwname);
  1373.     fprintf(fp_wdw,"$MFX:=%s;   %% Set MFX Group Name\n",c_var_name);
  1374.     fprintf(fp_wdw,"$WDW:=%s;   %% Set Window Name\n",wdwname);
  1375.   
  1376.     fprintf(fp_wdw,"o( $WDW,(\"01\") S . 1 3 9 1 Secure );   %% This Object Exits XBW\n");
  1377.     fprintf(fp_wdw,"bg( $WDW,(\"01\") . (\"Exit XbW\") );\n");
  1378.     fprintf(fp_wdw,"  cn( raK (\"@stop();\") );               %% Macro to Exit XbW\n");
  1379.     fprintf(fp_wdw,"  eg();\n");
  1380.   
  1381.     fprintf(fp_wdw,"o( $WDW,(\"02\") S T 11 3 30 1 Secure );   %% This Object starts the User Program\n");
  1382.     fprintf(fp_wdw,"bg( $WDW,(\"02\") . (\" Start Program %s\") );\n",pgmname);
  1383.     fprintf(fp_wdw,"  tk( (\"\") (\"%s\") );             %% Program name\n",pgmname);
  1384.     fprintf(fp_wdw,"  cn( wbX (\"%s\") );                %% Write MFX Group Before Start\n",c_var_name);
  1385.     fprintf(fp_wdw,"  cn( raX (\"%s\") );                %% Read MFX Group after End\n",c_var_name);
  1386.     fprintf(fp_wdw,"  eg();\n");
  1387.   
  1388.     fp_dwdw=fopen("makemfx.dwdw","r");
  1389.     if (fp_dwdw==NULL){puts("ERR: can't read scratch file!");exit(1);}
  1390.     while(!feof(fp_dwdw)){
  1391.       if(fgets(li,1000,fp_dwdw)){
  1392.         fputs(li,fp_wdw);
  1393.         }
  1394.       }
  1395.     }
  1396.   fclose(fp_dwdw);
  1397.   unlink("makemfx.dwdw");
  1398.   
  1399.   /*}}}  */
  1400.   return(0);
  1401.   }
  1402.  
  1403. int main(int argc, char **argv){
  1404.   extern FILE *yyin;
  1405.  
  1406.   yyin=NULL;
  1407.   if (argc>0){     yyin = fopen(argv[1],"r"); }
  1408.   if (yyin==NULL){ yyin = stdin; }
  1409.  
  1410. /*  yydebug = 1; */
  1411.  
  1412.   fp_trl=fopen("makemfx.emfx","w"); if (fp_trl==NULL){puts("ERR: can't write scratch file!");exit(1);}
  1413.  
  1414.   yyparse();
  1415.  
  1416.   fclose(fp_trl);
  1417.   {
  1418.     char li[1000];
  1419.     fp_trl=fopen("makemfx.emfx","r");
  1420.     if (fp_trl==NULL){puts("ERR: can't read scratch file!");exit(1);}
  1421.     while(!feof(fp_trl)){
  1422.       if(fgets(li,1000,fp_trl)){
  1423.         fputs(li,fp_wdw);
  1424.         }
  1425.       }
  1426.     }
  1427.  
  1428.   fprintf(fp_wdw,"SelectWdw( (\"W001\") );\n");
  1429.  
  1430.   fclose(fp_trl);
  1431.   unlink("makemfx.emfx");
  1432.  
  1433.   fprintf(fp_wdw,"End();\n\n");
  1434.  
  1435.   fprintf(fp_xbm,"End();\n\n");
  1436.   fprintf(fp_xbc,"\n#endif /* ALREADY_DEFINED_MFX_... */\n");
  1437.   fclose(fp_xbc);
  1438.   fclose(fp_xbm);
  1439.   fclose(fp_wdw);
  1440.  
  1441.   return(0);
  1442.   }
  1443.  
  1444.